1 package net.sourceforge.simplegamenet.chess; 2 3 public class ChessKnight extends ChessPiece { 4 5 public ChessKnight(int participantOwnerIndex, int x, int y) { 6 super(participantOwnerIndex, x, y); 7 } 8 9 public boolean isMoveAllowed(ChessPiece[] pieceGrid, 10 int destinationX, int destinationY) { 11 if (pieceGrid[destinationX * GRID_HEIGHT + destinationY] != null 12 && pieceGrid[destinationX * GRID_HEIGHT + destinationY] 13 .getParticipantsOwnerIndex() == participantOwnerIndex) { 14 return false; 15 } else if ((Math.abs(x - destinationX) + Math.abs(y - destinationY)) != 3 16 || Math.abs(x - destinationX) == 0 || Math.abs(y - destinationY) == 0) { 17 return false; 18 } else { 19 return true; 20 } 21 } 22 23 public int getPieceType() { 24 return ChessPieceType.KNIGHT; 25 } 26 27 public int getPieceValue() { 28 return 3; 29 } 30 31 }